<template>
  <div class="container-body">
    <!--header头部-->
    <el-row :gutter="20">
      <el-col :span="24">
        <p-header></p-header>
      </el-col>
    </el-row>

    <!--查看指标变化情况的入口按钮-->
    <div @click="openChangeView" class="showchange-btn">
      <i class="el-icon-search"></i>
      指标变化分析
      <i style="margin-top: 2px;" class="el-icon-d-arrow-right"></i>
    </div>
    <transition name="cv-popup">
      <!--指标变化情况抽屉栏-->
      <c-view
        :filters="filters"
        :changeTitle="changeTitle"
        :computeData="computeData"
        v-show="cv_side"
        class="cv-pop-up"
        ref="drawer"
        @cvCloseEvent="cvCloseEvent"
        @touchmove.stop.prevent>
      </c-view>
    </transition>

    <transition v-if="lv_side" name="lv-popup">
      <!-- 标签情况抽屉栏 -->
      <l-view
        :checkedNodes="checkedNodes"
        :active="active"
        :isDisabled="isDisabled"
        :inputText="inputText"
        :groupText="groupText"
        :tree_checked_keys="tree_checked_keys"
        :treeData="treeArr"
        @lvNextStepEvent="lvNextStepEvent"
        @lvLastStepEvent="lvLastStepEvent"
        @lgInputChange="lgInputChange"
        @lvCloseEvent="lvCloseEvent"
        @lvOnTreeSelected="lvOnTreeSelected"
        v-show="lv_side"
        class="lv-pop-up"
        @touchmove.stop.prevent
        @submitData="doSubmitData"></l-view>


    </transition>


    <el-form label-width="100px" label-position="top">
      <el-row :gutter="20">
        <el-col :span="10" :push="1">
          <el-form-item label="公司名称" prop="name">
            <el-select size="small" v-model="initCompanyVal" placeholder="请选择公司名称" @change="onCompanySelected">
              <el-option
                v-for="item in companyArr"
                :key="item.id"
                :label="item.name"
                :value="item.name">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="10" :push="3">
          <el-form-item label="业绩报类型" prop="region">
            <el-select size="small" v-model="initTypeVal" placeholder="请选择业绩报类型" @change="onTypeSelected">
              <el-option
                v-for="item in typeArr"
                :key="item.id"
                :label="item.name"
                :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="10" :push="1">
          <el-form-item label="报表年份" prop="name">
            <el-select size="small" v-model="initYearVal" placeholder="请选择报表年份" @change="onYearSelected">
              <el-option
                v-for="item in yearArr"
                :key="item.id"
                :label="item.name"
                :value="item.name"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="10" :push="3">
          <el-form-item label="生成份数" prop="name">
            <el-select size="small" v-model="initNumberVal" placeholder="请选择生成份数" @change="onNumSelected">
              <el-option
                v-for="item in numberArr"
                :key="item.id"
                :label="item.name"
                :value="item.name">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="16">
        <!--标签组-->
        <el-col :span="10" :push="1">
          <div class="label-group-title">标签组
            <div style="float: right">
              <div @click="openLabelView" style="display: inline;cursor: pointer;">
                <i class="el-icon-plus"/>
                新标签组
              </div>

            </div>
          </div>

          <div class="div_label" style="margin-top:9px;">
            <el-radio-group @change="onRadioSelected" v-model="initRadioVal">
              <el-radio
                v-for="(item,index) in groupArr"
                class="radio-style"
                :label="item.name"
                @mouseenter.native="enter(index)"
                @mouseleave.native="leave">
                <span>{{item.name}}</span>
                <el-tooltip placement="top" content="删除" :getPopupContainer="getPopupContainer">
                  <i
                    v-if="isClose == index"
                    @click.stop="deleteGroup(item.name)"
                    class="el-icon-circle-close-outline"
                    style="margin-left: 5px"
                  />
                </el-tooltip>
                <el-tooltip placement="top" content="编辑" :getPopupContainer="getPopupContainer">
                  <i
                    v-if="isClose == index && radioValue == item.name"
                    @click="openAndEditLabelView(item.name)"
                    class="el-icon-edit-outline"
                    style="margin-left: 5px"
                  />

                </el-tooltip>
              </el-radio>
            </el-radio-group>
          </div>
        </el-col>
        <!--已选标签-->
        <el-col :span="10" :push="3">
          <div class="label-group-title" title="">已选标签
            <div class="div_label" style="margin-top:9px;">
              <div style="height: 100%;"
                   v-loading="loading2"
                   element-loading-spinner="el-icon-loading"
                   element-loading-background="rgba(0, 0, 0, 0)">
                <el-tree
                  :data="treeArr"
                  show-checkbox
                  default-expand-all
                  node-key="key"
                  ref="trees"
                  :props="defaultProps"
                  style="color: white;background-color: rgba(128,0,128,0);"
                  @check="onTreeSelected"
                  :default-checked-keys="tree_checked_keys"
                  :filter-node-method="filterNode"
                ></el-tree>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>

    </el-form>


    <!--按钮-->
    <el-row :gutter="24">
      <el-col :span="24" style="text-align: center;margin: 20px auto;">
        <el-button type="primary" @click="validate">生成点评报</el-button>
      </el-col>
    </el-row>

  </div>

</template>

<script>
import axios from "axios";

import Header from '../../components/common/Top';
import {Card, Button, Table, Input, Tree, Row, Col, Message, Select, Form, Radio, Tag, Tooltip} from 'element-ui';
import ChangeView from "../components/changeview/ChangeView";
import LabelView from "../components/labelview/LabelView";

const warnMessage = (mess) => {
  Message.closeAll();
  Message.warning({
    message: mess,
    center: true,
  })
};

const errorMessage = (mess) => {
  Message.closeAll();
  Message.error({
    message: mess,
    center: true,
  })
};

const clearStr = (str, oldStr, newStr) => {
  var reg = new RegExp(str, "g");
  return oldStr.replace(reg, newStr);
};

/**
 * 设置显示的树结构
 * @param arr 数据
 */
const setShowTreeNode = (arr) => {
  for (var i in arr) {
    arr[i].label = arr[i].name;
    delete arr[i].name;
    if (arr[i].isParent && arr[i].is_analysis_class == 1) {
      arr[i].childrens = arr[i].children;
      delete arr[i].children;
    } else {
      setShowTreeNode(arr[i].children)
    }
  }
  // console.log("zhangxfzhangxf", arr)
};

/**
 * 设置为默认的树结构
 * @param arr 数据
 */
const setOriginalTreeNode = (arr) => {
  for (let i in arr) {
    if (arr[i].isParent && arr[i].childrens) {
      arr[i].children = arr[i].childrens;
      delete arr[i].childrens;
    } else {
      setShowTreeNode(arr[i].children)
    }
  }
};

/**
 * 获取自定义选中的树key方法
 * @param arr 数据
 */
const getDefaultCheckedKeys = (arr) => {
  let retArr = [];
  for (let i in arr) {
    if (arr[i].label) {
      retArr.push({
        label: arr[i].label,
        emotion: 0
      });
    } else {
      retArr.push({
        label: arr[i].name,
        emotion: 0
      });
    }
  }
  return retArr;
};

let id = 1000;

/**
 *  获取"增加"的数量
 */
const getUpNum = (arr) => {
  let num = 0;
  for (let i in arr) {
    if (arr[i].trendency == '增加') {
      num++;
    }
  }
  return num;
};

/**
 *  获取"减少"的数量
 */
const getDownNum = (arr) => {
  let num = 0;
  for (let i in arr) {
    if (arr[i].trendency == '减少') {
      num++;
    }
  }
  return num;
};

const genResult = (node) => {
  if (!Array.isArray(node)) return []
  if (node.length <= 0) return []
  const result = []
  node.forEach(item => {
    if (item.children && Array.isArray(item.children) && item.children.length > 0) {
      const children = genResult(item.children)
      if (children.length > 0) {
        const copyItem = {...item}
        copyItem.children = children
        result.push(copyItem)
      }
    } else {
      if (item.is_select) {
        result.push({...item})
      }
    }
  })
  return result
}


/**
 * 参数设置页面
 */
export default {
  name: "setting",
  components: {
    cView: ChangeView,
    lView: LabelView,
    pHeader: Header,
    elCard: Card,
    elButton: Button,
    elTable: Table,
    elInput: Input,
    elTree: Tree,
    elRow: Row,
    elCol: Col,
    elSelect: Select,
    elForm: Form,
    elRadio: Radio,
    elTag: Tag,
    elTooltip: Tooltip
  },
  data() {
    return {
      isDebug: false, //
      initCompanyVal: "中国平安",  //"公司名称"下拉选择默认值
      initTypeVal: "4", //"业绩报类型"下拉选择默认值
      initYearVal: "2017年", //"报表年份"下拉选择默认值
      initNumberVal: "3",  //"生成份数"下拉选择默认值
      initRadioVal: null, //标签组默认当前选中
      companyArr: [
        {
          id: 0,
          name: "中国平安"
        },
        {
          id: 1,
          name: "中国人寿"
        },
        {
          id: 2,
          name: "中国太保"
        },
        {
          id: 3,
          name: "新华保险"
        }
      ],
      typeArr: [
        {
          id: "1",
          name: "一季度"
        },
        {
          id: "2",
          name: "半年季"
        },
        {
          id: "3",
          name: "三季度"
        },
        {
          id: "4",
          name: "年报"
        }
      ],
      yearArr: [
        {
          id: 1,
          name: "2016年"
        },
        {
          id: 2,
          name: "2017年"
        },
        {
          id: 3,
          name: "2018年"
        }
      ],
      numberArr: [
        {
          id: 1,
          name: 1
        },
        {
          id: 3,
          name: 3
        },
        {
          id: 5,
          name: 5
        },
        {
          id: 10,
          name: 10
        }
      ],
      groupArr: [], //标签组
      curren_groupText_odname: null, //
      radioValue: null, //单选框选中的值
      isClose: null, //是否显示标签组单选框的删除小按钮
      cv_side: false, //变化抽屉控制器
      lv_side: false, //标签抽屉控制器
      allLabelParam: {},  //获取当前公司的标签的全部标签
      groupParam: {}, //获取标签组参数
      labelGroupParam: {}, //获取标签组标签参数
      tagArr: [], //标签
      treeArr: [],  //标签树-新增或编辑
      tree_checked_keys: [],  //默认选中的树节点id
      tree_checked_label: [],  //默认选中的树节点名称
      tags: [],  //已选中的树标签节点名称
      checkedNodes: [],  //已选中的树节点名称
      commonParam: {},  //公共参数
      requestData: {},
      actionType: 0,  //标签组drawer类型 0:新增 1:编辑
      historyRadioObj: {}, //历史单选框选中的标签组
      defaultRadioName: "", //默认单选中的数值
      lastRadioSelectObj: {},  //单选框最后一次选中的数据
      groupTitle: null,
      inputText: '',//默认的输入框内容
      currentInputText: null,
      isDisabled: true,  //下一步按钮是否可用
      active: '0', //用来判断是否下一步 '0':上一步;'1':下一步
      changeTitle: null, //指标变化标题
      computeData: [], //指标对比数据
      filters: [], //指标对比数据过滤数据格式
      defaultProps: {
        children: 'children',
        label: 'name',
        key: 'key'
      },
      loading2: false,

      // labelsUrl: 'http://192.168.1.147:9080/get_record2',
      // compute_url: "http://192.168.1.147:9080/compute",
      // update_group_url: 'http://192.168.1.147:9080/update_group',
      // add_group_url: 'http://192.168.1.147:9080/add_group',
      // del_group_url: 'http://192.168.1.147:9080/del_group',
      // get_group_url: 'http://192.168.1.147:9080/get_group',

      // labelsUrl: 'http://192.168.1.142:9080/get_record2',
      // compute_url: "http://192.168.1.142:9080/compute",
      // update_group_url: 'http://192.168.1.142:9080/update_group',
      // add_group_url: 'http://192.168.1.142:9080/add_group',
      // del_group_url: 'http://192.168.1.142:9080/del_group',
      // get_group_url: 'http://192.168.1.142:9080/get_group',

      labelsUrl: 'http://118.31.113.200:9080/get_record2',
      compute_url: "http://118.31.113.200:9080/compute",
      update_group_url: 'http://118.31.113.200:9080/update_group',
      add_group_url: 'http://118.31.113.200:9080/add_group',
      del_group_url: 'http://118.31.113.200:9080/del_group',
      get_group_url: 'http://118.31.113.200:9080/get_group',

      get_year_url: '',

      // labelsUrl: "/get_record2",
      // compute_url: "/compute",
      // update_group_url: "/update_group",
      // add_group_url: "/add_group",
      // del_group_url: "/del_group",
      // get_group_url: "/get_group",
      newGroupText: null
    };
  },
  computed: {},
  // 初始化数据
  created() {
    console.log("created()");
    this.test();
    this.initData();
  },
  mounted() {

  },
  updated() {
    this.$refs.trees.filter();
  },
  methods: {
    test() {
      let treeArr = [
        {
          "id": "1",
          "name": "业绩综述",
          "node_type": 0,
          "node_value": "",
          "output_unit": "",
          "ratio": "1.0",
          "isParent": true,
          "is_analysis_class": 0,
          "children": [
            {
              "id": "1_1",
              "name": "财务业绩",
              "node_type": 0,
              "node_value": "",
              "output_unit": "",
              "ratio": "1.0",
              "isParent": true,
              "is_analysis_class": 1,
              "children": [
                {
                  "id": "1_1_1",
                  "name": "总资产",
                  "node_type": 1,
                  "node_value": "5576903.0",
                  "output_unit": "百万元",
                  "ratio": 1000000,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "总资产",
                  "key": "业绩综述-财务业绩-总资产"
                },
                {
                  "id": "1_1_2",
                  "name": "内含价值",
                  "node_type": 1,
                  "node_value": "825173.0",
                  "output_unit": "百万元",
                  "ratio": 1000000,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "内含价值",
                  "key": "业绩综述-财务业绩-内含价值"
                },
                {
                  "id": "1_1_3",
                  "name": "净资产收益率（ROE）",
                  "node_type": 1,
                  "node_value": "0.0",
                  "output_unit": "%",
                  "ratio": 1,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "净资产收益率（ROE）",
                  "key": "业绩综述-财务业绩-净资产收益率（ROE）"
                },
                {
                  "id": "1_1_4",
                  "name": "归属于母公司股东的营运利润",
                  "node_type": 1,
                  "node_value": "9470800.0",
                  "output_unit": "百万元",
                  "ratio": 1000000,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "归属于母公司股东的营运利润",
                  "key": "业绩综述-财务业绩-归属于母公司股东的营运利润"
                },
                {
                  "id": "1_1_5",
                  "name": "归属于母公司股东的净利润",
                  "node_type": 1,
                  "node_value": "89088.0",
                  "output_unit": "百万元",
                  "ratio": 1000000,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "归属于母公司股东的净利润",
                  "key": "业绩综述-财务业绩-归属于母公司股东的净利润"
                },
                {
                  "id": "1_1_6",
                  "name": "每股股息",
                  "node_type": 1,
                  "node_value": "1.5",
                  "output_unit": "元",
                  "ratio": 1,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "每股股息",
                  "key": "业绩综述-财务业绩-每股股息"
                },
                {
                  "id": "1_1_7",
                  "name": "剩余边际",
                  "node_type": 1,
                  "node_value": "0.0",
                  "output_unit": "百万元",
                  "ratio": 1000000,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "剩余边际",
                  "key": "业绩综述-财务业绩-剩余边际"
                },
                {
                  "id": "1_1_8",
                  "name": "总保费收入",
                  "node_type": 1,
                  "node_value": "0.0",
                  "output_unit": "",
                  "ratio": 1,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "总保费收入",
                  "key": "业绩综述-财务业绩-总保费收入"
                }
              ],
              "title": "财务业绩",
              "key": "业绩综述-财务业绩"
            },
            {
              "id": "1_2",
              "name": "客户经营",
              "node_type": 0,
              "node_value": "",
              "output_unit": "",
              "ratio": "1.0",
              "isParent": true,
              "is_analysis_class": 1,
              "children": [
                {
                  "id": "1_2_1",
                  "name": "个人客户数",
                  "node_type": 1,
                  "node_value": "16573.0",
                  "output_unit": "万人",
                  "ratio": 10000,
                  "isParent": true,
                  "is_analysis_class": 0,
                  "children": [
                    {
                      "id": "1_2_1_1",
                      "name": "客均利润",
                      "node_type": 1,
                      "node_value": "355.85",
                      "output_unit": "元",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "客均利润",
                      "key": "业绩综述-客户经营-个人客户数-客均利润"
                    },
                    {
                      "id": "1_2_1_2",
                      "name": "客均合同数",
                      "node_type": 1,
                      "node_value": "2.32",
                      "output_unit": "份",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "客均合同数",
                      "key": "业绩综述-客户经营-个人客户数-客均合同数"
                    },
                    {
                      "id": "1_2_1_3",
                      "name": "新增客户数",
                      "node_type": 1,
                      "node_value": "4630.0",
                      "output_unit": "万人",
                      "ratio": 10000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "新增客户数",
                      "key": "业绩综述-客户经营-个人客户数-新增客户数"
                    }
                  ],
                  "title": "个人客户数",
                  "key": "业绩综述-客户经营-个人客户数"
                },
                {
                  "id": "1_2_2",
                  "name": "互联网用户量",
                  "node_type": 1,
                  "node_value": "0.0",
                  "output_unit": "百万元",
                  "ratio": 1000000,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "互联网用户量",
                  "key": "业绩综述-客户经营-互联网用户量"
                },
                {
                  "id": "1_2_3",
                  "name": "月均活跃用户",
                  "node_type": 1,
                  "node_value": "7356.0",
                  "output_unit": "万人",
                  "ratio": 10000,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "月均活跃用户",
                  "key": "业绩综述-客户经营-月均活跃用户"
                },
                {
                  "id": "1_2_4",
                  "name": "持有多家子公司合同的客户数",
                  "node_type": 1,
                  "node_value": "4723.0",
                  "output_unit": "万人",
                  "ratio": 10000,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "持有多家子公司合同的客户数",
                  "key": "业绩综述-客户经营-持有多家子公司合同的客户数"
                },
                {
                  "id": "1_2_5",
                  "name": "持有多家子公司合同的客户数占比",
                  "node_type": 1,
                  "node_value": "28.5",
                  "output_unit": "%",
                  "ratio": 1,
                  "isParent": false,
                  "is_analysis_class": 0,
                  "children": [],
                  "title": "持有多家子公司合同的客户数占比",
                  "key": "业绩综述-客户经营-持有多家子公司合同的客户数占比"
                }
              ],
              "title": "客户经营",
              "key": "业绩综述-客户经营"
            }
          ],
          "title": "业绩综述",
          "key": "业绩综述"
        },
        {
          "id": "2",
          "name": "主力业务",
          "node_type": 0,
          "node_value": "",
          "output_unit": "",
          "ratio": "1.0",
          "isParent": true,
          "is_analysis_class": 0,
          "children": [
            {
              "id": "2_1",
              "name": "寿险及健康险业务",
              "node_type": 0,
              "node_value": "",
              "output_unit": "",
              "ratio": "1.0",
              "isParent": true,
              "is_analysis_class": 0,
              "children": [
                {
                  "id": "2_1_1",
                  "name": "新业务价值_寿险",
                  "node_type": 1,
                  "node_value": "67357.0",
                  "output_unit": "百万元",
                  "ratio": 1000000,
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_1_1_1",
                      "name": "新业务价值率_寿险",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "%",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "新业务价值率_寿险",
                      "key": "主力业务-寿险及健康险业务-新业务价值_寿险-新业务价值率_寿险"
                    }
                  ],
                  "title": "新业务价值_寿险",
                  "key": "主力业务-寿险及健康险业务-新业务价值_寿险"
                },
                {
                  "id": "2_1_2",
                  "name": "利润分析_寿险",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_1_2_1",
                      "name": "归属于母公司股东的营运利润_寿险",
                      "node_type": 1,
                      "node_value": "52128.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "归属于母公司股东的营运利润_寿险",
                      "key": "主力业务-寿险及健康险业务-利润分析_寿险-归属于母公司股东的营运利润_寿险"
                    },
                    {
                      "id": "2_1_2_2",
                      "name": "归属于母公司股东的净利润_寿险",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "归属于母公司股东的净利润_寿险",
                      "key": "主力业务-寿险及健康险业务-利润分析_寿险-归属于母公司股东的净利润_寿险"
                    }
                  ],
                  "title": "利润分析_寿险",
                  "key": "主力业务-寿险及健康险业务-利润分析_寿险"
                },
                {
                  "id": "2_1_3",
                  "name": "代理人产能及收入_寿险",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_1_3_1",
                      "name": "代理人首年规模保费_寿险",
                      "node_type": 1,
                      "node_value": "8373.0",
                      "output_unit": "元",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "代理人首年规模保费_寿险",
                      "key": "主力业务-寿险及健康险业务-代理人产能及收入_寿险-代理人首年规模保费_寿险"
                    },
                    {
                      "id": "2_1_3_2",
                      "name": "代理人人均新业务价值_寿险",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "代理人人均新业务价值_寿险",
                      "key": "主力业务-寿险及健康险业务-代理人产能及收入_寿险-代理人人均新业务价值_寿险"
                    },
                    {
                      "id": "2_1_3_3",
                      "name": "代理人活动率_寿险",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "代理人活动率_寿险",
                      "key": "主力业务-寿险及健康险业务-代理人产能及收入_寿险-代理人活动率_寿险"
                    },
                    {
                      "id": "2_1_3_4",
                      "name": "代理人个险新单件数",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "代理人个险新单件数",
                      "key": "主力业务-寿险及健康险业务-代理人产能及收入_寿险-代理人个险新单件数"
                    },
                    {
                      "id": "2_1_3_5",
                      "name": "代理人收入",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "元",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "代理人收入",
                      "key": "主力业务-寿险及健康险业务-代理人产能及收入_寿险-代理人收入"
                    },
                    {
                      "id": "2_1_3_6",
                      "name": "代理人数量",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "代理人数量",
                      "key": "主力业务-寿险及健康险业务-代理人产能及收入_寿险-代理人数量"
                    }
                  ],
                  "title": "代理人产能及收入_寿险",
                  "key": "主力业务-寿险及健康险业务-代理人产能及收入_寿险"
                },
                {
                  "id": "2_1_4",
                  "name": "保费分析_寿险",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_1_4_1",
                      "name": "保费收入_寿险",
                      "node_type": 1,
                      "node_value": "388642.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "保费收入_寿险",
                      "key": "主力业务-寿险及健康险业务-保费分析_寿险-保费收入_寿险"
                    },
                    {
                      "id": "2_1_4_2",
                      "name": "代理人渠道新业务规模保费_寿险",
                      "node_type": 1,
                      "node_value": "136657.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "代理人渠道新业务规模保费_寿险",
                      "key": "主力业务-寿险及健康险业务-保费分析_寿险-代理人渠道新业务规模保费_寿险"
                    },
                    {
                      "id": "2_1_4_3",
                      "name": "已赚保费_寿险",
                      "node_type": 1,
                      "node_value": "384567.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "已赚保费_寿险",
                      "key": "主力业务-寿险及健康险业务-保费分析_寿险-已赚保费_寿险"
                    },
                    {
                      "id": "2_1_4_4",
                      "name": "剩余边际_寿险",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "剩余边际_寿险",
                      "key": "主力业务-寿险及健康险业务-保费分析_寿险-剩余边际_寿险"
                    },
                    {
                      "id": "2_1_4_5",
                      "name": "保单继续率_寿险",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": true,
                      "is_analysis_class": 0,
                      "children": [
                        {
                          "id": "2_1_4_5_1",
                          "name": "13个月保单继续率_寿险",
                          "node_type": 1,
                          "node_value": "91.8",
                          "output_unit": "%",
                          "ratio": 1,
                          "isParent": false,
                          "is_analysis_class": 0,
                          "children": [],
                          "title": "13个月保单继续率_寿险",
                          "key": "主力业务-寿险及健康险业务-保费分析_寿险-保单继续率_寿险-13个月保单继续率_寿险"
                        },
                        {
                          "id": "2_1_4_5_2",
                          "name": "25个月保单继续率_寿险",
                          "node_type": 1,
                          "node_value": "88.0",
                          "output_unit": "%",
                          "ratio": 1,
                          "isParent": false,
                          "is_analysis_class": 0,
                          "children": [],
                          "title": "25个月保单继续率_寿险",
                          "key": "主力业务-寿险及健康险业务-保费分析_寿险-保单继续率_寿险-25个月保单继续率_寿险"
                        }
                      ],
                      "title": "保单继续率_寿险",
                      "key": "主力业务-寿险及健康险业务-保费分析_寿险-保单继续率_寿险"
                    }
                  ],
                  "title": "保费分析_寿险",
                  "key": "主力业务-寿险及健康险业务-保费分析_寿险"
                },
                {
                  "id": "2_1_5",
                  "name": "收益率_寿险",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_1_5_1",
                      "name": "总投资收益率_寿险",
                      "node_type": 1,
                      "node_value": "6.1",
                      "output_unit": "%",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "总投资收益率_寿险",
                      "key": "主力业务-寿险及健康险业务-收益率_寿险-总投资收益率_寿险"
                    },
                    {
                      "id": "2_1_5_2",
                      "name": "净投资收益率_寿险",
                      "node_type": 1,
                      "node_value": "5.8",
                      "output_unit": "%",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "净投资收益率_寿险",
                      "key": "主力业务-寿险及健康险业务-收益率_寿险-净投资收益率_寿险"
                    }
                  ],
                  "title": "收益率_寿险",
                  "key": "主力业务-寿险及健康险业务-收益率_寿险"
                },
                {
                  "id": "2_1_6",
                  "name": "偿付能力_寿险",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_1_6_1",
                      "name": "偿付能力充足率_寿险",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "%",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "偿付能力充足率_寿险",
                      "key": "主力业务-寿险及健康险业务-偿付能力_寿险-偿付能力充足率_寿险"
                    }
                  ],
                  "title": "偿付能力_寿险",
                  "key": "主力业务-寿险及健康险业务-偿付能力_寿险"
                }
              ],
              "title": "寿险及健康险业务",
              "key": "主力业务-寿险及健康险业务"
            },
            {
              "id": "2_2",
              "name": "财产保险业务",
              "node_type": 0,
              "node_value": "",
              "output_unit": "",
              "ratio": "1.0",
              "isParent": true,
              "is_analysis_class": 0,
              "children": [
                {
                  "id": "2_2_1",
                  "name": "利润分析_产险",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_2_1_1",
                      "name": "归属于母公司股东的营运利润_产险",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "归属于母公司股东的营运利润_产险",
                      "key": "主力业务-财产保险业务-利润分析_产险-归属于母公司股东的营运利润_产险"
                    },
                    {
                      "id": "2_2_1_2",
                      "name": "归属于母公司股东的净利润_产险",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "归属于母公司股东的净利润_产险",
                      "key": "主力业务-财产保险业务-利润分析_产险-归属于母公司股东的净利润_产险"
                    }
                  ],
                  "title": "利润分析_产险",
                  "key": "主力业务-财产保险业务-利润分析_产险"
                },
                {
                  "id": "2_2_2",
                  "name": "保费分析_产险",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_2_2_1",
                      "name": "已赚保费_产险",
                      "node_type": 1,
                      "node_value": "188219.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": true,
                      "is_analysis_class": 0,
                      "children": [
                        {
                          "id": "2_2_2_1_1",
                          "name": "已赚保费增长率_产险",
                          "node_type": 1,
                          "node_value": "22.7",
                          "output_unit": "%",
                          "ratio": 1,
                          "isParent": false,
                          "is_analysis_class": 0,
                          "children": [],
                          "title": "已赚保费增长率_产险",
                          "key": "主力业务-财产保险业务-保费分析_产险-已赚保费_产险-已赚保费增长率_产险"
                        }
                      ],
                      "title": "已赚保费_产险",
                      "key": "主力业务-财产保险业务-保费分析_产险-已赚保费_产险"
                    },
                    {
                      "id": "2_2_2_2",
                      "name": "原保险保费收入_产险",
                      "node_type": 1,
                      "node_value": "215984.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": true,
                      "is_analysis_class": 0,
                      "children": [
                        {
                          "id": "2_2_2_2_1",
                          "name": "车险保费收入_产险",
                          "node_type": 1,
                          "node_value": "170508.0",
                          "output_unit": "百万元",
                          "ratio": 1000000,
                          "isParent": false,
                          "is_analysis_class": 0,
                          "children": [],
                          "title": "车险保费收入_产险",
                          "key": "主力业务-财产保险业务-保费分析_产险-原保险保费收入_产险-车险保费收入_产险"
                        },
                        {
                          "id": "2_2_2_2_2",
                          "name": "非机动车险保险保费收入_产险",
                          "node_type": 1,
                          "node_value": "38929.0",
                          "output_unit": "百万元",
                          "ratio": 1000000,
                          "isParent": false,
                          "is_analysis_class": 0,
                          "children": [],
                          "title": "非机动车险保险保费收入_产险",
                          "key": "主力业务-财产保险业务-保费分析_产险-原保险保费收入_产险-非机动车险保险保费收入_产险"
                        }
                      ],
                      "title": "原保险保费收入_产险",
                      "key": "主力业务-财产保险业务-保费分析_产险-原保险保费收入_产险"
                    }
                  ],
                  "title": "保费分析_产险",
                  "key": "主力业务-财产保险业务-保费分析_产险"
                },
                {
                  "id": "2_2_3",
                  "name": "综合成本率_产险",
                  "node_type": 1,
                  "node_value": "96.2",
                  "output_unit": "%",
                  "ratio": 1,
                  "isParent": false,
                  "is_analysis_class": 1,
                  "children": [],
                  "title": "综合成本率_产险",
                  "key": "主力业务-财产保险业务-综合成本率_产险"
                },
                {
                  "id": "2_2_4",
                  "name": "收益率_产险",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_2_4_1",
                      "name": "净资产收益率_产险",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "%",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "净资产收益率_产险",
                      "key": "主力业务-财产保险业务-收益率_产险-净资产收益率_产险"
                    }
                  ],
                  "title": "收益率_产险",
                  "key": "主力业务-财产保险业务-收益率_产险"
                }
              ],
              "title": "财产保险业务",
              "key": "主力业务-财产保险业务"
            },
            {
              "id": "2_3",
              "name": "银行业务",
              "node_type": 0,
              "node_value": "",
              "output_unit": "",
              "ratio": "1.0",
              "isParent": true,
              "is_analysis_class": 0,
              "children": [
                {
                  "id": "2_3_1",
                  "name": "贷款质量_银行业务",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_3_1_1",
                      "name": "不良贷款率_银行业务",
                      "node_type": 1,
                      "node_value": "1.7",
                      "output_unit": "%",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "不良贷款率_银行业务",
                      "key": "主力业务-银行业务-贷款质量_银行业务-不良贷款率_银行业务"
                    },
                    {
                      "id": "2_3_1_2",
                      "name": "拨备覆盖率_银行业务",
                      "node_type": 1,
                      "node_value": "151.08",
                      "output_unit": "%",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "拨备覆盖率_银行业务",
                      "key": "主力业务-银行业务-贷款质量_银行业务-拨备覆盖率_银行业务"
                    }
                  ],
                  "title": "贷款质量_银行业务",
                  "key": "主力业务-银行业务-贷款质量_银行业务"
                },
                {
                  "id": "2_3_2",
                  "name": "利润分析_银行业务",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_3_2_1",
                      "name": "归属于母公司股东的净利润_银行业务",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "归属于母公司股东的净利润_银行业务",
                      "key": "主力业务-银行业务-利润分析_银行业务-归属于母公司股东的净利润_银行业务"
                    },
                    {
                      "id": "2_3_2_2",
                      "name": "营业收入_银行业务",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "营业收入_银行业务",
                      "key": "主力业务-银行业务-利润分析_银行业务-营业收入_银行业务"
                    }
                  ],
                  "title": "利润分析_银行业务",
                  "key": "主力业务-银行业务-利润分析_银行业务"
                },
                {
                  "id": "2_3_3",
                  "name": "零售业务_银行业务",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_3_3_1",
                      "name": "零售业务营业收入_银行业务",
                      "node_type": 1,
                      "node_value": "46692.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "零售业务营业收入_银行业务",
                      "key": "主力业务-银行业务-零售业务_银行业务-零售业务营业收入_银行业务"
                    },
                    {
                      "id": "2_3_3_2",
                      "name": "零售业务营业收入占比_银行业务",
                      "node_type": 1,
                      "node_value": "44.1",
                      "output_unit": "%",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "零售业务营业收入占比_银行业务",
                      "key": "主力业务-银行业务-零售业务_银行业务-零售业务营业收入占比_银行业务"
                    },
                    {
                      "id": "2_3_3_3",
                      "name": "零售业务净利润_银行业务",
                      "node_type": 1,
                      "node_value": "15679.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "零售业务净利润_银行业务",
                      "key": "主力业务-银行业务-零售业务_银行业务-零售业务净利润_银行业务"
                    },
                    {
                      "id": "2_3_3_4",
                      "name": "零售客户数量_银行业务",
                      "node_type": 1,
                      "node_value": "6991.0",
                      "output_unit": "万人",
                      "ratio": 10000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "零售客户数量_银行业务",
                      "key": "主力业务-银行业务-零售业务_银行业务-零售客户数量_银行业务"
                    }
                  ],
                  "title": "零售业务_银行业务",
                  "key": "主力业务-银行业务-零售业务_银行业务"
                }
              ],
              "title": "银行业务",
              "key": "主力业务-银行业务"
            },
            {
              "id": "2_4",
              "name": "金融科技与医疗科技业务",
              "node_type": 0,
              "node_value": "",
              "output_unit": "",
              "ratio": "1.0",
              "isParent": true,
              "is_analysis_class": 0,
              "children": [
                {
                  "id": "2_4_1",
                  "name": "陆金所控股",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_4_1_1",
                      "name": "资产贷款余额_陆金所控股",
                      "node_type": 1,
                      "node_value": "288434.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "资产贷款余额_陆金所控股",
                      "key": "主力业务-金融科技与医疗科技业务-陆金所控股-资产贷款余额_陆金所控股"
                    },
                    {
                      "id": "2_4_1_2",
                      "name": "30天以上逾期率_陆金所控股",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "30天以上逾期率_陆金所控股",
                      "key": "主力业务-金融科技与医疗科技业务-陆金所控股-30天以上逾期率_陆金所控股"
                    },
                    {
                      "id": "2_4_1_3",
                      "name": "资产管理规模_陆金所控股",
                      "node_type": 1,
                      "node_value": "461699.0",
                      "output_unit": "百万元",
                      "ratio": 1000000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "资产管理规模_陆金所控股",
                      "key": "主力业务-金融科技与医疗科技业务-陆金所控股-资产管理规模_陆金所控股"
                    },
                    {
                      "id": "2_4_1_4",
                      "name": "累积借款人数_陆金所控股",
                      "node_type": 1,
                      "node_value": "749.0",
                      "output_unit": "万人",
                      "ratio": 10000,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "累积借款人数_陆金所控股",
                      "key": "主力业务-金融科技与医疗科技业务-陆金所控股-累积借款人数_陆金所控股"
                    },
                    {
                      "id": "2_4_1_5",
                      "name": "投后估值_陆金所控股",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "投后估值_陆金所控股",
                      "key": "主力业务-金融科技与医疗科技业务-陆金所控股-投后估值_陆金所控股"
                    }
                  ],
                  "title": "陆金所控股",
                  "key": "主力业务-金融科技与医疗科技业务-陆金所控股"
                },
                {
                  "id": "2_4_2",
                  "name": "平安好医生",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_4_2_1",
                      "name": "净利润_平安好医生",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "净利润_平安好医生",
                      "key": "主力业务-金融科技与医疗科技业务-平安好医生-净利润_平安好医生"
                    },
                    {
                      "id": "2_4_2_2",
                      "name": "累积咨询量_平安好医生",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "累积咨询量_平安好医生",
                      "key": "主力业务-金融科技与医疗科技业务-平安好医生-累积咨询量_平安好医生"
                    }
                  ],
                  "title": "平安好医生",
                  "key": "主力业务-金融科技与医疗科技业务-平安好医生"
                },
                {
                  "id": "2_4_3",
                  "name": "金融壹账通",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_4_3_1",
                      "name": "合作银行数_金融壹账通",
                      "node_type": 1,
                      "node_value": "468.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "合作银行数_金融壹账通",
                      "key": "主力业务-金融科技与医疗科技业务-金融壹账通-合作银行数_金融壹账通"
                    },
                    {
                      "id": "2_4_3_2",
                      "name": "合作非银金融机构_金融壹账通",
                      "node_type": 1,
                      "node_value": "1890.0",
                      "output_unit": "家",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "合作非银金融机构_金融壹账通",
                      "key": "主力业务-金融科技与医疗科技业务-金融壹账通-合作非银金融机构_金融壹账通"
                    },
                    {
                      "id": "2_4_3_3",
                      "name": "投后估值_金融壹账通",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "投后估值_金融壹账通",
                      "key": "主力业务-金融科技与医疗科技业务-金融壹账通-投后估值_金融壹账通"
                    }
                  ],
                  "title": "金融壹账通",
                  "key": "主力业务-金融科技与医疗科技业务-金融壹账通"
                },
                {
                  "id": "2_4_4",
                  "name": "平安医保科技",
                  "node_type": 0,
                  "node_value": "",
                  "output_unit": "",
                  "ratio": "1.0",
                  "isParent": true,
                  "is_analysis_class": 1,
                  "children": [
                    {
                      "id": "2_4_4_1",
                      "name": "“城市一账通”APP上线城市数量_平安医保科技",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "“城市一账通”APP上线城市数量_平安医保科技",
                      "key": "主力业务-金融科技与医疗科技业务-平安医保科技-“城市一账通”APP上线城市数量_平安医保科技"
                    },
                    {
                      "id": "2_4_4_2",
                      "name": "投后估值_平安医保科技",
                      "node_type": 1,
                      "node_value": "0.0",
                      "output_unit": "",
                      "ratio": 1,
                      "isParent": false,
                      "is_analysis_class": 0,
                      "children": [],
                      "title": "投后估值_平安医保科技",
                      "key": "主力业务-金融科技与医疗科技业务-平安医保科技-投后估值_平安医保科技"
                    }
                  ],
                  "title": "平安医保科技",
                  "key": "主力业务-金融科技与医疗科技业务-平安医保科技"
                }
              ],
              "title": "金融科技与医疗科技业务",
              "key": "主力业务-金融科技与医疗科技业务"
            }
          ],
          "title": "主力业务",
          "key": "主力业务"
        }];
      // this.zhangxf01(treeArr);
      let selectedIdArr = ['1', '1_2', '1_2_1'];
      this.setSelectArr(selectedIdArr);
      this.traverse_tree1(treeArr);
      console.log("pppppppppppppppp", treeArr);


      /* console.log('test')
       console.log(JSON.stringify(this.setShowArr(treeArr)));
       console.log(this.setShowArr(treeArr));*/
    },
    setShowArr(arr) {
      // 当前节点是否为分析大类，0:否；1：分析大类；2: 板块；3：板块下的业务；5：集团名称
      // 为分析大类时，不需要显示下面的子节点；其它情况需要显示子节点
      let is_analysis_class;
      let isParent; //是否是父节点
      let obj;  //下标对象
      for (let i in arr) {
        obj = arr[i];
        is_analysis_class = obj.is_analysis_class;
        isParent = obj.isParent;
        obj.isShow = true;

        if (obj.children) {
          this.setShowArr()
        }
        /*for (let i2 in obj.children) {
          obj.children[i2].isShow = true;
          if (obj.children[i2].isParent && obj.children[i2].is_analysis_class == 1) { //分析大类
            for (let i3 in obj.children[i2].children) {
              obj.children[i2].children[i3].isShow = false;
            }
          }
        }*/

      }
      return arr;
    },
    doSubmitData(data) {  //提交按钮事件
      console.log('return from selector', data);

      if (this.actionType == 0) { //新增
        let addParam = {
          group_name: this.inputText,
          company: this.commonParam.company,
          labels: JSON.stringify(data)
        };
        this.addGroupReq(addParam);
      } else {  //编辑
        var name = null;
        if (this.lastRadioSelectObj.groupText) {
          name = this.lastRadioSelectObj.groupText;
        } else {
          name = this.initRadioVal;
        }
        let updateParam = {
          new_group_name: this.currentInputText,
          old_group_name: name,
          company: this.commonParam.company,
          labels: JSON.stringify(data)
        }
        this.updateGroupReq(updateParam);
      }

    },
    compute_next_step(select_data, all_data) {
      for (let i in all_data) { //开始遍历树
        this.find_select_node(all_data[i], select_data);
      }
      console.log("all data", all_data)
    },

    find_select_node(tmp_node, select_data) {
      if (select_data.find(x => x.key === tmp_node.key)) {  //选中
        tmp_node.is_select = true;
        if (tmp_node.children) {  //当前节点选中，有子节点,开始找子节点是否选中
          this.judge_child_node(tmp_node.children, select_data);
        }
      }
      else {  //未选中
        if (tmp_node.children) {  //当前节点未选中，有子节点，开始找子节点是否选中
          let is_find = this.judge_child_node(tmp_node.children, select_data);
          if (is_find) {
            tmp_node.is_select = true;
          }
          else {
            tmp_node.is_select = false;
          }
        }
        else {
          tmp_node.is_select = false;
        }
      }
    },

    judge_child_node(child_list, select_data) {
      let is_find = false;
      for (let j in child_list) {
        if (select_data.find(x => x.key === child_list[j].key)) { //子节点是否选中
          // console.log("----------", '---', child_list[j].label, '===', child_list[j].children)
          child_list[j].is_select = true;
          is_find = true;
          if (child_list[j].children) { //是否有子节点
            let my_find = this.judge_child_node(child_list[j].children, select_data);  //递归遍历
            // console.log("----------", my_find, '---', child_list[j].label)
            if (!my_find) {
              this.set_child_selected(child_list[j].children)
            }
          }
        }
        else {  //子节点未被选中
          if (child_list[j].children) { //是否有子节点
            let my_find = this.judge_child_node(child_list[j].children, select_data);
            if (my_find) {
              child_list[j].is_select = true;
              is_find = true
            }
            else {
              child_list[j].is_select = false;
            }
          }
          else {
            child_list[j].is_select = false;
          }
        }
      }
      return is_find;
    },

    set_child_selected(node, is_selected) {
      if (Array.isArray(node) && node.length > 0) {
        node.forEach(item => {
          item.is_select = is_selected
          if (item.children && Array.isArray(item.children)) {
            this.set_child_selected(item.children, is_selected)
          }
        })
      }
    },

    traverse_tree1(arr) {
      for (let i in arr) {
        if (arr[i].is_analysis_class == 1) {
          arr[i].isShow = true;
          if (arr[i].children) {
            this.traverse_tree2(arr[i]);
          }
        } else {
          arr[i].isShow = true;
          if (arr[i].children) {
            this.traverse_tree1(arr[i].children);
          }

        }
      }
    },

    traverse_tree2(obj) {
      for (let i in obj.children) {
        obj.children[i].isShow = false;
        if (obj.children[i].children) {
          this.traverse_tree2(obj.children[i]);
        }
      }
    },


    setSelectArr(arr) {
      for (let i in arr) {
        console.log(arr[i]);

      }
    },

    initData() {
      this.active = '0';
      let historyParam = JSON.parse(sessionStorage.getItem("historyParam"));
      let year = clearStr("年", this.initYearVal, "");
      this.changeTitle = this.initCompanyVal;
      let initParam = {
        company: this.initCompanyVal,
        type: this.initTypeVal,
        year: year,
        number: this.initNumberVal
      };
      console.log("initData()", historyParam);
      if (historyParam) {
        this.commonParam = historyParam;
        this.initCompanyVal = historyParam.company;  //公司
        if (historyParam.type == "1") {       //类型
          this.initTypeVal = "一季度";
        } else if (historyParam.type == "2") {
          this.initTypeVal = "三季度";
        } else if (historyParam.type == "3") {
          this.initTypeVal = "半年季";
        } else {
          this.initTypeVal = "年报";
        }
        this.initYearVal = historyParam.year + "年"; //年份
        this.initNumberVal = historyParam.number;  //份数
      } else {
        this.initCompanyVal = initParam.company;
        this.commonParam = initParam;
      }

      this.allLabelParam = {
        company: this.commonParam.company,
        year: year,
        type: this.commonParam.type
      };

      this.requestData = {
        company: this.commonParam.company,
        year: this.commonParam.year,
        type: this.commonParam.type
      };
      console.log("初始化的数据：", this.commonParam);
      this.groupParam = {
        company: this.commonParam.company,
        group_name: null,
      };
      this.getGroupReq(this.groupParam);
      this.getAllLabelReq(this.allLabelParam);
      this.active = '1';
    },
    //公司名称选择
    onCompanySelected(val) {
      console.log(`onCompanySelected(): ${val}`);
      let company = val;
      this.allLabelParam.company = company;
      this.tagArr = [];
      this.tree_checked_keys = [];
      this.changeTitle = company;
      this.requestData.company = val;
      this.commonParam.company = val;
      this.groupParam = {
        company: this.commonParam.company,
        group_name: null,
      }
      this.labelGroupParam = null;
      this.initRadioVal = null;
      this.historyRadioObj = {};
      this.groupArr = [];
      this.treeArr = null;
      this.radioValue = null;
      sessionStorage.removeItem("historyRadioName");
      this.getGroupReq(this.groupParam);
    },
    //业绩报类型选择
    onTypeSelected(val) {
      console.log(`onTypeSelected(): ${val}`);
      let type = val;
      this.allLabelParam.type = type;

      this.requestData.type = val;
      this.commonParam.type = val;
      this.treeArr = null;
    },
    //报表年份选择
    onYearSelected(val) {
      val = clearStr("年", val, "")
      console.log(`onYearSelected(): ${val}`);
      let year = val;
      this.allLabelParam.year = year;

      this.requestData.year = val;
      this.commonParam.year = val;
      this.treeArr = null;
    },
    //生成份数选择
    onNumSelected(val) {
      console.log(`onNumSelected(): ${val}`)
      this.commonParam.number = val;
    },
    //标签单选框选择
    onRadioSelected(val) {
      console.log(`onRadioSelected():${val}`);
      this.lastRadioSelectObj.groupText = val;
      this.radioValue = val;
      this.historyRadioObj = {
        name: val
      };
      var name = val;  //标签组名称
      this.labelGroupParam = {
        company: this.commonParam.company,
        group_name: name
      };
      this.getGroupLabel(this.labelGroupParam)
    },
    //鼠标离开
    leave() {
      this.isClose = -1;
    },
    //鼠标经过
    enter(index) {
      if (this.groupArr[index].type == 1) {  //自定义
        this.isClose = index;
      } else {  //内置
        this.isClose = -1;
      }
    },
    //获取年份
    getYearReq(param) {
      console.log("getYearReq()", param);
      var mess = null;
      axios.get(this.get_year_url, {params: param}).then(res => {
        if (res.data.respcode != 0) {
          mess = res.data.respmesg;
          errorMessage(mess);
          return;
        }
        ;
        this.yearArr = res.data.results;
      })
        .catch(err => {
          console.log("获取标签组-网络请求异常：", err.message);
        });
    },
    //获取标签组
    getGroupReq(param) {
      console.log("getGroup()", param);
      let mess = null;
      axios.get(this.get_group_url, {params: param}).then(res => {
        if (res.data.respcode != 0) {
          mess = res.data.respmesg;
          errorMessage(mess);
          return;
        }

        if (res.data.results.length > 0) {
          this.groupArr = res.data.results;
          var name = null;
          console.log("之前点击的单选项", this.historyRadioObj.name);
          if (this.historyRadioObj.name) {
            console.log("1")
            name = this.historyRadioObj.name;
          } else if (sessionStorage.getItem("historyRadioName")) {
            console.log("2");
            name = sessionStorage.getItem("historyRadioName");
            this.historyRadioObj.name = name;
          } else {
            console.log("3")
            name = res.data.results[0].name;
            this.defaultRadioName = name;
          }
          this.lastRadioSelectObj.groupText = name;
          this.initRadioVal = name;
          console.log("之前点击的单选项", this.initRadioVal);
          this.radioValue = name;
          this.labelGroupParam = {
            company: this.commonParam.company,
            group_name: name
          };
          this.getGroupLabel(this.labelGroupParam);
        } else {
          this.groupArr = [];
          this.tagArr = [];
          this.tree_checked_keys = [];
          this.radioValue = null;
        }
      })
        .catch(err => {
          console.log("获取标签组-网络请求异常：", err.message);
        });
    },
    //获取标签组下的标签
    getGroupLabel(param) {
      console.log("getGroupLabel()", param);
      let mess = null;
      let labelSelected = [];
      if (this.isDebug) {
        labelSelected = [{"id": 2, "label": "业绩综述-财务业绩"}];
        this.tree_checked_keys = getDefaultCheckedKeys(labelSelected);
      }
      {
        axios.get(this.get_group_url, {params: param}).then(res => {
          if (res.data.respcode != 0) {
            mess = res.data.respmesg;
            errorMessage(mess);
            return;
          }
          // labelSelected = res.data.results[0].labels;
          labelSelected = res.data.results[0].keys;
          console.log(labelSelected);
          this.tree_checked_keys = getDefaultCheckedKeys(labelSelected);
          console.log('选中的标签zhangxf', this.tree_checked_keys);
          this.tagArr = labelSelected;
          this.lastRadioSelectObj.label = labelSelected;

          let arr = [];
          for (let i in labelSelected) {
            arr.push(labelSelected[i].label);
          }
          this.tree_checked_keys = arr;


          this.checkedNodes = res.data.results[0].nodes;
          this.compute_next_step(this.checkedNodes, this.treeArr);
          console.log('选中的标签 checkedNodes', this.checkedNodes);
        })
          .catch(err => {
            console.log("获取标签组详细-网络请求异常：", err.message);
          });
      }

    },
    //删除标签组
    deleteGroupReq(param) {
      console.log("deleteGroupReq()", param)
      let mess = null;
      axios.get(this.del_group_url, {params: param}).then(res => {
        if (res.data.respcode != 0) {
          mess = res.data.respmesg;
          errorMessage(mess);
          return;
        }
        this.groupParam = {
          company: this.commonParam.company,
          group_name: null,
        };
        this.getGroupReq(this.groupParam);
      })
        .catch(err => {
          console.log("删除标签组-网络请求异常：", err.message);
        });
    },
    //增加标签组
    addGroupReq(param) {
      console.log("addGroupReq()", param);
      let mess = null;
      axios.get(this.add_group_url, {params: param}).then(res => {
        if (res.data.respcode != 0) {
          mess = res.data.respmesg;
          errorMessage(mess);
          return;
        }
        this.lv_side = false;
        this.active = '0';
        this.groupParam = {
          company: this.commonParam.company,
          group_name: null,
        }
        this.getGroupReq(this.groupParam);
      })
        .catch(err => {
          console.log("增加标签组-网络请求异常：", err.message);
        });
    },
    //修改标签组
    updateGroupReq(param) {
      console.log("updateGroupReq()", param);
      let mess = null;
      axios.get(this.update_group_url, {params: param}).then(res => {
        if (res.data.respcode != 0) {
          mess = res.data.respmesg;
          errorMessage(mess);
          return;
        }
        this.groupParam = {
          company: this.commonParam.company,
          group_name: null,
        }
        this.getGroupReq(this.groupParam);
        this.lv_side = false;
      })
        .catch(err => {
          console.log("修改标签组-网络请求异常：", err.message);
        });
    },
    //获取标签数据
    getAllLabelReq(param) {
      console.log("getAllLabelReq()", param);
      this.loading2 = true;
      let isDebug = this.isDebug;
      let treeArr = [{
        id: "1",
        name: "业绩综述",
        node_type: 0,
        node_value: "",
        output_unit: "",
        ratio: "1.0",
        isParent: true,
        is_analysis_class: 0,
        isLeaf: true,
        children: [
          {
            id: "1_1",
            name: "财务业绩",
            node_type: 0,
            node_value: "",
            output_unit: "",
            ratio: "1.0",
            isParent: true,
            is_analysis_class: 0,
            title: "财务业绩",
            key: "业绩综述-财务业绩",
          },
          {
            id: "1_2",
            name: "客户经营",
            node_type: 0,
            node_value: "",
            output_unit: "",
            ratio: "1.0",
            isParent: true,
            is_analysis_class: 1,
            children: [
              {
                id: "1_2_1",
                name: "个人客户数",
                node_type: 1,
                node_value: "16573.0",
                output_unit: "万人",
                ratio: 10000,
                isParent: true,
                is_analysis_class: 1,
                children: [
                  {
                    id: "1_2_1_1",
                    name: "客均利润",
                    node_type: 1,
                    node_value: "355.85",
                    output_unit: "元",
                    ratio: 1,
                    isParent: false,
                    is_analysis_class: 1,
                    children: [],
                    title: "客均利润",
                    key: "业绩综述-客户经营-个人客户数-客均利润"
                  },
                  {
                    id: "1_2_1_2",
                    name: "客均合同数",
                    node_type: 1,
                    node_value: "2.32",
                    output_unit: "份",
                    ratio: 1,
                    isParent: false,
                    is_analysis_class: 1,
                    children: [],
                    title: "客均合同数",
                    key: "业绩综述-客户经营-个人客户数-客均合同数"
                  },
                  {
                    id: "1_2_1_3",
                    name: "新增客户数",
                    node_type: 1,
                    node_value: "4630.0",
                    output_unit: "万人",
                    ratio: 10000,
                    isParent: false,
                    is_analysis_class: 1,
                    children: [],
                    title: "新增客户数",
                    key: "业绩综述-客户经营-个人客户数-新增客户数"
                  }
                ],
                title: "个人客户数",
                key: "业绩综述-客户经营-个人客户数"
              },
              {
                id: "1_2_2",
                name: "互联网用户量",
                node_type: 1,
                node_value: "0.0",
                output_unit: "百万元",
                ratio: 1000000,
                isParent: false,
                is_analysis_class: 1,
                children: [],
                title: "互联网用户量",
                key: "业绩综述-客户经营-互联网用户量"
              },
              {
                id: "1_2_3",
                name: "月均活跃用户",
                node_type: 1,
                node_value: "7356.0",
                output_unit: "万人",
                ratio: 10000,
                isParent: false,
                is_analysis_class: 1,
                children: [],
                title: "月均活跃用户",
                key: "业绩综述-客户经营-月均活跃用户"
              },
              {
                id: "1_2_4",
                name: "持有多家子公司合同的客户数",
                node_type: 1,
                node_value: "4723.0",
                output_unit: "万人",
                ratio: 10000,
                isParent: false,
                is_analysis_class: 1,
                children: [],
                title: "持有多家子公司合同的客户数",
                key: "业绩综述-客户经营-持有多家子公司合同的客户数"
              },
              {
                id: "1_2_5",
                name: "持有多家子公司合同的客户数占比",
                node_type: 1,
                node_value: "28.5",
                output_unit: "%",
                ratio: 1,
                isParent: false,
                is_analysis_class: 1,
                children: [],
                title: "持有多家子公司合同的客户数占比",
                key: "业绩综述-客户经营-持有多家子公司合同的客户数占比"
              }
            ],
            title: "客户经营",
            key: "业绩综述-客户经营"
          }
        ],
        title: "业绩综述",
        key: "业绩综述"
      }];
      if (isDebug) {
        if (treeArr) {
          // setShowTreeNode(treeArr);
        }
        this.treeArr = treeArr;
      } else {
        let mess = null;
        if (
          param.company &&
          param.year &&
          param.type
        ) {
          axios
            .get(this.labelsUrl, {
              params: param
            })
            .then(res => {
              if (res.data.respcode != 0) {
                mess = res.data.respmesg;
                errorMessage(mess);
                this.loading2 = false;
                return;
              }
              treeArr = res.data.result;
              // if (treeArr) {
              //   setShowTreeNode(treeArr);
              // }
              if (treeArr) {
                this.traverse_tree1(treeArr);
                this.setArrLabelEmotion(treeArr);
                this.treeArr = treeArr;
                if (this.actionType == 1) {
                  console.log(">>>>>>>", this.checkedNodes);
                  this.compute_next_step(this.checkedNodes, this.treeArr);
                  console.log("编辑获取标签数据后遍历树后的数据", this.treeArr);
                } else {
                  console.log("新增获取标签数据后遍历树后的数据", this.treeArr);
                }
                // this.$refs.trees.filter();
              }
              this.loading2 = false;
            })
            .catch(err => {
              console.log("获取全部标签数据-网络请求异常：", err.message);
              this.loading2 = false;
            });
        }
      }
    },
    setArrLabelEmotion(arr) {
      if (Array.isArray(arr) && arr && arr.length > 0) {
        for (let i in arr) {
          arr[i].emotion = 0; //默认正面
          if (Array.isArray(arr[i].children) && arr[i].children && arr[i].children.length > 0) {
            this.setArrLabelEmotion(arr[i].children);
          }
        }
      }
    },
    //获取指标对比数据
    computeReq(paramData) {
      console.log("computeReq()", paramData);
      let mess = null;
      let isDebug = this.isDebug;
      if (isDebug) {
        this.computeData = [
          {
            "key": 1,
            "name": "13个月保单继续率",
            "trendency": "增加",
            "value": 91.8,
            "change": 0.4
          },
          {
            "key": 2,
            "name": "25个月保单继续率",
            "trendency": "减少",
            "value": 88,
            "change": 1.5
          },
          {
            "key": 3,
            "name": "保费收入_寿险",
            "trendency": "增加",
            "value": 388642000000,
            "change": "33.43%"
          },
          {
            "key": 4,
            "name": "保费收入",
            "trendency": "减少",
            "value": 605035000000,
            "change": "28.85%"
          },
          {
            "key": 5,
            "name": "保户质押贷款",
            "trendency": "增加",
            "value": 83203000000,
            "change": "28.73%"
          },
          {
            "key": 6,
            "name": "保险营销员每月人均首年保险业务收入",
            "trendency": "减少",
            "value": 8373,
            "change": "7.06%"
          },
          {
            "key": 7,
            "name": "保险营销员人数",
            "trendency": "增加",
            "value": 1386,
            "change": "24.75%"
          },
          {
            "key": 8,
            "name": "不良贷款率_银行业务",
            "trendency": "减少",
            "value": 1.7,
            "change": 0.04
          },
          {
            "key": 9,
            "name": "综合偿付能力充足率_产险",
            "trendency": "增加",
            "value": 217.5,
            "change": 49.8
          }
        ];
        this.filters = [{
          text: '增加(' + getUpNum(this.computeData) + ')',
          value: '增加'
        }, {text: '减少(' + getDownNum(this.computeData) + ')', value: '减少'}]
      } else {
        if (
          paramData.company &&
          paramData.year &&
          paramData.type
        ) {
          axios
            .get(this.compute_url, {
              params: paramData
            })
            .then(res => {
              if (res.data.respcode != 0) {
                mess = res.data.respmesg;
                errorMessage(mess);
                return;
              }
              this.computeData = res.data.results.history;
              getUpNum(this.computeData);
              getDownNum(this.computeData);
              this.filters = [{
                text: '增加(' + getUpNum(this.computeData) + ')',
                value: '增加'
              }, {text: '减少(' + getDownNum(this.computeData) + ')', value: '减少'}]
            })
            .catch(err => {
              console.log("获取指标对比数据-网络请求异常：", err.message);
            });
        } else {
          mess = "请完成配置参数后再请求网络";
          errorMessage(mess);
        }
      }
    },
    //浮层渲染父节点，默认渲染到 body 上
    getPopupContainer(trigger) {
      return trigger.parentElement;
    },
    //外层调用组件方注册变更方法，将组件内的数据变更，同步到组件外的数据状态中
    onResultChange(val) {
      this.inputText = val;
    },

    filterNode(value, data, node) {
      if (data.is_select) {
        return true;
      } else {
        return false;
      }
    },
    onTreeSelected(checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys) {
      console.log('OnTreeSelected', checkedKeys);
      let tagsArr = [];
      let checkedNodesArr = checkedKeys.checkedNodes;
      console.log("onTreeSelected 选中的节点", checkedNodesArr);
      this.compute_next_step(checkedNodesArr, this.treeArr);
      if (checkedNodesArr) {
        for (let i in checkedNodesArr) {
          tagsArr.push({
            id: checkedNodesArr[i].id,
            name: checkedNodesArr[i].key
          })
        }
      }
      this.tags = tagsArr;
      checkedNodesArr = getDefaultCheckedKeys(tagsArr);
      this.checkedNodes = checkedNodesArr;


      //编辑
      var name = this.initRadioVal;
      let updateParam = {
        new_group_name: name,
        old_group_name: name,
        company: this.commonParam.company,
        labels: JSON.stringify(genResult(this.treeArr))
      }
      this.updateGroupReq(updateParam);
    },
    //标签抽屉树选中事件监听
    lvOnTreeSelected(checkedKeys) {
      console.log('lvOnTreeSelected', checkedKeys);
      let tagsArr = [];
      let checkedNodesArr = checkedKeys.checkedNodes;
      console.log("已选中的节点", JSON.stringify(checkedNodesArr));
      this.compute_next_step(checkedNodesArr, this.treeArr);
      console.log("====", this.treeArr);
      // setShowTreeNode(this.treeArr);
      if (checkedNodesArr) {
        for (let i in checkedNodesArr) {
          tagsArr.push({
            id: checkedNodesArr[i].id,
            name: checkedNodesArr[i].key
          })
        }
      }
      this.tags = tagsArr;
      checkedNodesArr = getDefaultCheckedKeys(tagsArr);
      this.checkedNodes = checkedNodesArr;
      let isDisabled = true;

      if (this.actionType == 0) { //新增
        if (!this.currentInputText || JSON.stringify(this.checkedNodes) == '[]') {
          isDisabled = true;
        } else {
          isDisabled = false;
        }
      } else {  //编辑
        console.log(this.currentInputText);
        console.log(!this.currentInputText);
        console.log(JSON.stringify(this.checkedNodes) == '[]');
        if (!this.currentInputText || JSON.stringify(this.checkedNodes) == '[]') {
          console.log("zhangxfzhangxfzhangxfzhangxf");
          isDisabled = true;
        } else {
          if (this.currentInputText != this.lastRadioSelectObj.groupText || JSON.stringify(this.checkedNodes) != JSON.stringify(this.tree_checked_keys)) {
            console.log("11111111111111111111");
            isDisabled = false;
          } else {
            console.log("22222222222222222222");
            isDisabled = true;
          }
        }
      }
      this.isDisabled = isDisabled;
      console.log(this.tags);
      console.log(this.checkedNodes);
    },
    //打开标签抽屉
    openLabelView() {
      this.active = '0';
      this.actionType = 0;
      this.tree_checked_keys = [];
      this.groupText = "新增标签组";
      this.inputText = '';
      this.checkedNodes = [];
      this.curren_groupText_odname = null;
      this.getAllLabelReq(this.allLabelParam);

      this.$nextTick(() => {
        this.lv_side = true;
      })
    },
    //打开并编辑标签抽屉
    openAndEditLabelView(val) {
      this.active = '0';
      this.curren_groupText_odname = val;
      this.actionType = 1;
      let groups = this.lastRadioSelectObj;
      this.lastRadioSelectObj.groupText = val;
      this.groupText = "编辑标签组\"" + val + "\"";
      this.inputText = val;
      console.log("点击编辑的单选框", val);
      console.log("最后一次单选框选中的数据", groups);
      if (groups.groupText == val) {
        let arr = [];
        for (let i in groups.label) {
          arr.push(groups.label[i].label);
        }
        this.tree_checked_keys = arr;
      } else {
        this.tree_checked_keys = [];
      }
      // this.checkedNodes = this.tree_checked_keys;
      console.log("openAndEditLabelView后", this.tree_checked_keys);
      this.getAllLabelReq(this.allLabelParam);
      this.currentInputText = val;
      this.$nextTick(() => {
        this.lv_side = true;
      })

    },
    //点击删除选中的标签组
    deleteGroup(name) {
      var param = {company: this.commonParam.company, group_name: name}
      this.deleteGroupReq(param);
      this.historyRadioObj = {};
      sessionStorage.removeItem("historyRadioName");
    },
    //显示指标变化抽屉按钮
    openChangeView() {
      console.log("showChange()");
      this.cv_side = true;

      this.computeReq(this.requestData);
    },
    cvCloseEvent() {
      this.cv_side = false;
      this.lv_side = false;
    },
    lvCloseEvent() {  //取消
      console.log('lvCloseEvent');
      this.cv_side = false;
      this.lv_side = false;
      this.isDisabled = true;
      this.tree_checked_keys = [];
      this.currentInputText = null;
      this.checkedNodes = [];
      this.active = '0';
      this.initData();
    },
    lvNextStepEvent() { //下一步
      console.log('lvNextStepEvent');
      this.active = '1';
    },
    lvLastStepEvent() {  //上一步
      console.log('lvLastStepEvent');
      this.active = '0';
    },
    lvAppend(data) {
      const newChild = {id: id++, label: 'testtest', children: []};
      if (!data.children) {
        this.$set(data, 'children', []);
      }
      data.children.push(newChild);
    },
    /*    lvRemove(node, data) {
          const parent = node.parent;
          const children = parent.data.children || parent.data;
          const index = children.findIndex(d => d.id === data.id);
          children.splice(index, 1);
        },
        lvRenderContent(node, data) {  //渲染内容
          console.log('lvRenderContent', node);
          console.log('lvRenderContent', data);
          return (
            <span
              style="flex: 1; display: flex; align-items: center; justify-content: space-between; font-size: 14px; padding-right: 8px;"><span>
            <span>{node.label}</span>
          </span>
          <span>
          <el-button style="font-size: 12px;" type="text" on-click={() => this.lvAppend(data)}>Append</el-button>
          <el-button style="font-size: 12px;" type="text" on-click={() => this.lvRemove(node, data)}>Delete</el-button>
          </span>
          </span>);
        },*/
    //标签组输入框的value变化监听
    lgInputChange(val) {
      console.log('lvlgInputChange', val);
      this.currentInputText = val;
      let isDisabled = true;

      /*      if (this.actionType == 0) { //新增
              if (!this.currentInputText || JSON.stringify(this.checkedNodes) == '[]') {
                isDisabled = true;
              } else {
                isDisabled = false;
              }
            } else {  //编辑
              console.log(this.currentInputText);
              console.log(!this.currentInputText);
              console.log(JSON.stringify(this.checkedNodes) == '[]');
              if (!this.currentInputText || JSON.stringify(this.checkedNodes) == '[]') {
                console.log("zhangxfzhangxfzhangxfzhangxf");
              } else {
                if (this.currentInputText != this.lastRadioSelectObj.groupText  ) {
                  console.log("11111111111111111111");
                  isDisabled = false;
                } else {
                  console.log("22222222222222222222");
                }
              }
            }*/
      console.log("》》》》》actionType", JSON.stringify(this.checkedNodes) != '[]');


      if (this.curren_groupText_odname != this.currentInputText
        && JSON.stringify(this.checkedNodes) != '[]') {

        isDisabled = false;
      }


      this.isDisabled = isDisabled;

      this.inputText = val;
    },
    //最终全页面提交
    validate() {
      this.commonParam.labels = this.tagArr;
      let mess = null;
      if (
        !this.commonParam.company ||
        !this.commonParam.type ||
        !this.commonParam.year ||
        !this.commonParam.number ||
        this.commonParam.labels == "[]" ||
        this.commonParam.labels == [] ||
        this.commonParam.labels.length <= 0 ||
        !this.commonParam.labels
      ) {
        mess = '请完成配置后再提交';
        warnMessage(mess);
        return;
      }
      console.log("validate", this.commonParam);
      this.commonParam.labels = JSON.stringify(this.tagArr);
      this.$router.push({
        path: "/preview",
        query: {
          commonParam: this.commonParam
        }
      });
      let historyParam = JSON.stringify(this.commonParam);
      let historyRadioName = null;
      if (this.historyRadioObj.name) {
        historyRadioName = this.historyRadioObj.name;
      } else {
        historyRadioName = this.defaultRadioName;
      }
      sessionStorage.setItem("historyParam", historyParam);
      sessionStorage.setItem("historyRadioName", historyRadioName);
    },
    //已选标签删除
    handleClose(name) {
      console.log("handleClose()", name);
      for (let i = this.tagArr.length; i > 0; i--) {
        if (this.tagArr[i - 1].label === name) {
          this.tagArr.splice(i - 1, 1);
        }
      }
      var name = null;
      if (this.lastRadioSelectObj.groupText) {
        name = this.lastRadioSelectObj.groupText;
      } else {
        name = this.initRadioVal;
      }
      for (let i in this.tagArr) {
        this.tagArr[i].is_select = true;
      }
      var param = {
        new_group_name: name,
        old_group_name: name,
        company: this.commonParam.company,
        labels: JSON.stringify(this.tagArr)
      }
      this.updateGroupReq(param);
    },
  },
  destroyed: function () {
    Message.closeAll();
  }
};

</script>

<style>
  .yellow {
    color: #ff8004;
  }

  .red {
    color: red;
  }

  .green {
    color: green;
  }

  .container-body {
    margin: 10px;
    /*background-color: rgba(79, 148, 205, 0.1);*/
  }

  h1 {
    font-weight: bold;
  }

  .div_label {
    height: 300px;
    border: 1px solid #409eff;
    border-radius: 5px;
    overflow-x: auto;
    padding: 5px;
  }

  .radio-style {
    display: block;
    height: 30px;
    lineHeight: 30px;
    margin: 10px;
    color: #FFFFFF;
  }

  .showchange-btn {
    cursor: pointer;
    z-index: 6;
    position: absolute;
    left: 5px;
    top: 30%;
    width: 30px;
    background: #409eff;
    border-radius: 2px;
    color: #ffffff;
    text-align: center;
    padding: 5px;
  }

  .label-group-title {
    font-size: 14px;
    color: #ffffff;
    margin-top: 10px;
  }

  .div_label > .ant-radio-group {
    width: 100%;
  }

  .table-operations > button {
    margin: 8px 8px 0 0;
    float: right;
  }

  th {
    width: 100px;
  }

  .el-card__body {
    padding: 10px !important;
  }

  .el-card {
    border-width: 0 !important;
  }

  .input-color {
    color: #ffffff;
  }

  th.column-money,
  td.column-money {
    text-align: left !important;
  }

  .rise {
    color: green;
  }

  .table-title {
    text-align: center;
    width: 100%;
    clear: both;
  }

  .table-content {
    height: 403px;
    overflow-y: auto;
    padding: 24px;
  }

  .tree-css {
    /*margin: 20px auto;*/
    max-height: 650px;
    overflow-y: auto;
    padding: 0 24px;
  }

  .label-group-content {
    display: inline;
    border: 2px solid #ffffff;
    border-radius: 5px;
    background: #FFFFFF;
    margin-left: 20px;
    padding: 5px;
  }

  .table-operations {
    margin-bottom: 16px;
  }

  .name {
    width: 46%;
  }

  .value, .change, .trend {
    width: 18%;
  }

  .add-label-group {
    background: #fff;
    borderStyle: dashed;
    display: block;
    width: 80px;
    margin: 0 10px 10px;
  }

  .icons {
    /*color: #40a9ff;*/
  }

  .ant-drawer-body {
    padding: 0 !important;
  }

  .ant-drawer-title {
    font-size: 18px !important;
  }

  .ant-drawer-wrapper-body {
    overflow: hidden !important;
  }

  .el-form-item__label {
    color: #ffffff !important;
  }

  .el-select {
    width: 100% !important;
  }

  .el-form--label-top .el-form-item__label {
    padding: 0 !important;
  }

  .el-tag {
    /*color: #ffffff !important;*/
    margin: 2px !important;
  }

  .el-scrollbar__wrap {
    overflow: hidden !important;
  }

  .el-radio-group {
    width: 100% !important;
    overflow-x: hidden !important;
  }

  /* 变化抽屉 */
  .cv-pop-up {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    opacity: 1;
    z-index: 502;
    background: rgba(0, 0, 0, 0.1);
  }

  .cv-popup-enter-to,
  .cv-popup-leave-to {
    transition: transform 0.5s;
    transform: translate(0px, 0px);
  }

  .cv-popup-enter,
  .cv-popup-leave-to {
    opacity: 0;
    -webkit-transform: translate(-100%, 0px);
    transform: translate(-100%, 0px);
    -webkit-transition: opacity 0.5s ease-in-out 0.5s,
    -webkit-transform 0.5s ease-in-out;
    transition: opacity 0.5s ease-in-out 0.5s, transform 0.5s ease-in-out;
  }

  /* end */
  .cv-content {
    z-index: 503;
    position: fixed;
    background: #ffffff;
    top: 0px;
    left: 0px;
    bottom: 0px;
    /*right: 60%;*/
    /*width: 730px;*/
    -webkit-overflow-scrolling: touch;
  }

  .cv-content-title {
    display: flex;
    justify-content: space-between;
    padding: 16px 24px;
    font-size: 18px;
    line-height: 22px;
    font-weight: 500;
    color: rgba(0, 0, 0, .85);
    border-bottom: 1px solid #e8e8e8;
  }

  /* 标签抽屉 */
  .lv-pop-up {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    opacity: 1;
    z-index: 502;
    background: rgba(0, 0, 0, 0.1);
  }

  .lv-popup-enter-to,
  .lv-popup-leave-to {
    transition: transform 0.5s;
    transform: translate(0px, 0px);
  }

  .lv-popup-enter,
  .lv-popup-leave-to {
    opacity: 0;
    -webkit-transform: translate(200%, 0px);
    transform: translate(200%, 0px);
    -webkit-transition: opacity 0.5s ease-in-out 0.5s,
    -webkit-transform 0.5s ease-in-out;
    transition: opacity 0.5s ease-in-out 0.5s, transform 0.5s ease-in-out;
  }

  /* end */
  .lv-content {
    z-index: 503;
    position: fixed;
    background: #ffffff;
    top: 0px;
    right: 0px;
    bottom: 0px;
    /*width: 730px;*/
    width: 50%;
    -webkit-overflow-scrolling: touch;
  }

  .lv-content-title {
    display: flex;
    justify-content: space-between;
    padding: 16px 24px;
    font-size: 18px;
    line-height: 22px;
    font-weight: 500;
    color: rgba(0, 0, 0, .85);
    border-bottom: 1px solid #e8e8e8;
  }

  .close {
    padding: 17px;
    text-align: left;
    color: rgba(0, 122, 255, 1);
  }

  .lv-content-tree {
    padding: 16px 24px;
  }

  .lv-content-tree-label {
    display: flex;
    align-items: center;
    margin: 10px 0 10px 0;
  }

  .lv-content-tree-label > h4 {
    color: #000;
    margin: 0px;
  }

  .lv-content-tree-label > div {
    color: black;
    height: 25px;
    line-height: 30px
  }

  .el-tree {
    height: 100%;
    overflow-y: auto !important;
  }

  .lv-footer {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    border-top: 1px solid #e9e9e9;
    text-align: right;
    padding: 10px 16px
  }

  .cv-content-table {
    height: 100%;
    overflow-y: auto
  }

  .el-radio__input.is-checked + .el-radio__label {
    color: white;
  }

  .el-tree-node__content:hover {
    background-color: rgba(128, 0, 128, 0) !important;
  }

</style>
